var t = n = 0, imgcount;
	$(document).ready(function(){	
		//火狐浏览器有点问题，其他网站使用时，这句命令可以不用
		$("#banner_list a").filter(":visible").fadeOut(1).parent().children().eq(0).fadeIn(1);
		//以下为正常代码		
		imgcount=$("#banner_list a").length;
		$("#banner_list a:not(:first-child)").hide();
		$("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt'));
		$("#banner_info").click(function(){window.open($("#banner_list a:first-child").attr('href'), "_blank")});
		$("#banner li").click(function() {
			var i = $(this).text() - 1;//获取Li元素内的值，即1，2，3，4
			n = i;
			if (i >= imgcount) return;
			$("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt'));
			$("#banner_info").unbind().click(function(){window.open($("#banner_list a").eq(i).attr('href'), "_blank")})
			$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
			$(this).toggleClass("on");
			$(this).siblings().removeAttr("class");
		});
		t = setInterval("showAuto()", 4000);
		$("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
	});
	
	function showAuto()
	{
		n = n >=(imgcount - 1) ? 0 : ++n;
		$("#banner li").eq(n).trigger('click');
	}
	
$(function() {

   if(!window.ActiveXObject){
        $("#zhishi").css("margin-left","4px");
    }else{
        $("#banner_bg").css("left","2px");
        $("#banner").css("margin-top","23px");
        $("#tonggao").css("margin-top","26px");
        $("#tongtitle").css("top","20px");
        $("#line").css("margin-left","35px");
    }
   initZYbg();
   InitZS();
   $(window).resize(function() {
    initZYbg();
   });
});
function initZYbg(){ 
	//alert($(document).width());
     if(document.body.clientWidth<957){
	        $("#mainleft").width(0);
	        $("#mainright").width(0);
	         $("#mainleft").css("display","none");
		    $("#mainright").css("display","none");
        }else{
	       if(!window.ActiveXObject){
		        var wid=($(document).width()-953)/2;
		        $("#mainleft").width(wid);
		        $("#mainright").width(wid);
		        $("#mainleft").css("display","block");
		        $("#mainright").css("display","block");
		    }else{
		        var wid=($(document).width()-974)/2;
		        if(wid>0){
		        	$("#mainleft").width(wid);
			        $("#mainright").width(wid);
			        $("#mainleft").css("display","block");
			        $("#mainright").css("display","block");
		        }
		    }
        }
}
//点击切换国省市
function ChengeNav(obj){
	if($("#"+obj).attr("class")=="button"){
	  $("#"+obj).removeClass("button").addClass("default");
	  if(obj=="nva1"){
		  $("#nva1").css("background","url(img/qt/guo.jpg)");
		  $("#nva2").css("background","url(img/qt/sheng1.jpg)");
		  $("#nva3").css("background","url(img/qt/shi1.jpg)");
		  $("#nva2").removeClass("default").addClass("button");
		  $("#nva3").removeClass("default").addClass("button");
		  $("#guo").css("display","");
		  $("#sheng").css("display","none");
		  $("#shi").css("display","none");
		  $("#tgmore").attr("href","tglist.do?type=1");
	  }else if(obj=="nva2"){
		  $("#nva1").css("background","url(img/qt/guo1.jpg)");
		  $("#nva2").css("background","url(img/qt/sheng.jpg)");
		  $("#nva3").css("background","url(img/qt/shi1.jpg)");
		  $("#nva1").removeClass("default").addClass("button");
		  $("#nva3").removeClass("default").addClass("button");
		  $("#guo").css("display","none");
		  $("#sheng").css("display","");
		  $("#shi").css("display","none");
		  $("#tgmore").attr("href","tglist.do?type=2");
	  }else if(obj=="nva3"){
		  $("#nva1").css("background","url(img/qt/guo1.jpg)");
		  $("#nva2").css("background","url(img/qt/sheng1.jpg)");
		  $("#nva3").css("background","url(img/qt/shi.jpg)");
		  $("#nva2").removeClass("default").addClass("button");
		  $("#nva1").removeClass("default").addClass("button");
		  $("#guo").css("display","none");
		  $("#sheng").css("display","none");
		  $("#shi").css("display","");
		  $("#tgmore").attr("href","tglist.do?type=3");
	  }
	 
	}
}
//初始化知识
function InitZS(){
	 $("#zhishi").html("");
	IndexDwr.CateList(uid,function(data){
		list=data;
		count=data.length;	
		if(count>0&&m<count){
			IndexDwr.getList(1,list[m].id,list[m].name,returnZhiShi);
			m++;
		}
	});
}
function returnZhiShi(data){
	   var zhishi="";
	   var trs="";
	   var pages=pageTemp.replace("#CNAME#",data.temp).replace("#Total#",data.totalPages==0?1:data.totalPages)
	                  .replace("#Curcent#",data.pageNo);
	   if(data.pageNo==1){
		   pages=pages.replace("#ClassPre#","disprepage").replace("#ClickPre#","");
	   }else{
		    pages=pages.replace("#ClassPre#","prepage").replace("#ClickPre#","onclick='ChengePage("+(data.pageNo-1)+","+data.temp1+",\""+data.temp+"\")'");
	   }
       if(data.pageNo==data.totalPages||data.totalPages==0){
		   pages=pages.replace("#ClassNext#","disnextpage").replace("#ClickNext#","");
	   }else{
		    pages=pages.replace("#ClassNext#","nextpage").replace("#ClickNext#","onclick='ChengePage("+(data.pageNo+1)+","+data.temp1+",\""+data.temp+"\")'");
	   }
	   zhishi=template.replace("#Page#",pages).replace("#CID#",data.temp1)
	                  .replace("#CID#",data.temp1).replace("#CID#",data.temp1);
	   for(var i=0;i<data.knows.length;i++){
		   trs=trs+trsTemp.replace("#Title#",getByteVal(data.knows[i].title,40)).replace("#Type#",data.knows[i].type+"")
		                  .replace("#ID#",data.knows[i].id);
		   if(data.knows[i].type>0){
			   trs=trs.replace("#IMG#", '<a href="download.do?id='+data.knows[i].id+'" target="_blank"><img alt="" style="border:0px;" src="img/gl/format/'+data.knows[i].type+'.gif"/></a>')
		   }else{
			   trs=trs.replace("#IMG#","");
		   }
	   }
	   zhishi=zhishi.replace("#TRS#", trs);
	   $("#zhishi").append(zhishi);
	   if(count>0&&m<count){
			IndexDwr.getList(1,list[m].id,list[m].name,returnZhiShi);
			m++;
		}
	   initZYbg();
      if (isIE6) {  
	      $(".zhishis").css("margin-right","2px");
	    } 
}
function ChengePage(pageNo,cid,cname){
    IndexDwr.getList(pageNo,cid,cname,function(data){
	   var trs="";
	   var pages=pageTemp.replace("#CNAME#",data.temp).replace("#Total#",data.totalPages==0?1:data.totalPages)
	                  .replace("#Curcent#",data.pageNo);
	   if(data.pageNo==1){
		   pages=pages.replace("#ClassPre#","disprepage").replace("#ClickPre#","");
	   }else{
		    pages=pages.replace("#ClassPre#","prepage").replace("#ClickPre#","onclick='ChengePage("+(data.pageNo-1)+","+data.temp1+",\""+data.temp+"\")'");
	   }
       if(data.pageNo==data.totalPages||data.totalPages==0){
		   pages=pages.replace("#ClassNext#","disnextpage").replace("#ClickNext#","");
	   }else{
		    pages=pages.replace("#ClassNext#","nextpage").replace("#ClickNext#","onclick='ChengePage("+(data.pageNo+1)+","+data.temp1+",\""+data.temp+"\")'");
	   }
       $("#Tr_"+cid).html(pages);
       for(var i=0;i<data.knows.length;i++){
		   trs=trs+trsTemp.replace("#Title#",getByteVal(data.knows[i].title,40)).replace("#Type#",data.knows[i].type+"")
		                  .replace("#ID#",data.knows[i].id);
		   if(data.knows[i].type>0){
			   trs=trs.replace("#IMG#", '<a href="download.do?id='+data.knows[i].id+'" target="_blank"><img alt="" style="border:0px;" src="img/gl/format/'+data.knows[i].type+'.gif"/></a>')
		   }else{
			   trs=trs.replace("#IMG#","");
		   }
	   }
       $("#Tbl_"+cid).html(trs);
    });	
}

var template=' <div class="zhishis"> '+
   ' <div class="zszuo"></div> '+
   ' <div class="zszhong">'+
   '   <div class="zstitletop">'+
   '      <table cellpadding="0" cellspacing="0" style="float:left;margin:0px;">'+
   '        <tr id="Tr_#CID#">'+
   '           #Page#'+
	'       </tr>'+
    '     </table>'+
    '  </div>'+
    '  <div class="zsmain">'+
    '    <table  cellpadding="0" cellspacing="0" style="float:left;margin:0px;">'+
    '      <tbody id="Tbl_#CID#">#TRS# </tbody>'+
    '   </table> '+
    '  </div>'+
    '  <div class="zsmore">'+
    '    <a href="zslist.do?cid=#CID#" target="_blank"><img style="border:0px;" src="img/qt/more.jpg"/></a>'+
    '  </div>'+
    '</div>'+
    '<div class="zsyou"></div>'+
   '</div>';

var trsTemp='      <tr>'+
'       <td class="zsdot"></td>'+
'       <td class="zstitle">'+
'        <a href="zsdetail.do?id=#ID#" target="_blank">#Title#</a>'+
'       </td>'+
'       <td class="img">'+
'        #IMG#'+
'       </td>'+
'      </tr>';
var pageTemp=   ' <td class="zstt">#CNAME#</td>'+
	'           <td class="zstotal">共#Total#页 第#Curcent#页</td>'+
	'           <td class="zspage" style="">'+
	'               <div class="#ClassNext#" #ClickNext# ></div>'+
	'               <div class="midpage"  ></div>'+
	'               <div class="#ClassPre#" #ClickPre#></div>'+
	'           </td>';
